﻿#ifndef SURFACE_H
#define SURFACE_H

#include <QWidget>
#include <QMouseEvent>
#include <QFileDialog>
#include <QPaintEvent>
#include <QImage>
#include <QPainter>

#include "reader.h"

class Surface : public QWidget
{
    Q_OBJECT
public:
    explicit Surface(QWidget *parent = nullptr);
    ~Surface();

    bool init(QString filename);
    void paintEvent(QPaintEvent *event);
	void closeEvent(QCloseEvent *event)
	{
		reader->stop();
	}

    void refresh();

public slots:
    void onUpdateImage(QImage image);
    void onError();
    void onOpen();

private:
    QImage image;
    Reader * reader = nullptr;
    QString m_filename;
    bool isOpen = false;
};

#endif // SURFACE_H
